package com.ruoyi.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.ProjectRecoveryDetail;
import com.ruoyi.project.service.IProjectRecoveryDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工程复盘详情Controller
 * 
 * @author liboyu
 * @date 2024-05-30
 */
@RestController
@RequestMapping("/project/recoveryDetail")
public class ProjectRecoveryDetailController extends BaseController
{
    @Autowired
    private IProjectRecoveryDetailService projectRecoveryDetailService;

    /**
     * 查询工程复盘详情列表
     */
    @PreAuthorize("@ss.hasPermi('project:recoveryDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectRecoveryDetail projectRecoveryDetail)
    {
        startPage();
        List<ProjectRecoveryDetail> list = projectRecoveryDetailService.selectProjectRecoveryDetailList(projectRecoveryDetail);
        return getDataTable(list);
    }

    /**
     * 导出工程复盘详情列表
     */
    @PreAuthorize("@ss.hasPermi('project:recoveryDetail:export')")
    @Log(title = "工程复盘详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectRecoveryDetail projectRecoveryDetail)
    {
        List<ProjectRecoveryDetail> list = projectRecoveryDetailService.selectProjectRecoveryDetailList(projectRecoveryDetail);
        ExcelUtil<ProjectRecoveryDetail> util = new ExcelUtil<ProjectRecoveryDetail>(ProjectRecoveryDetail.class);
        util.exportExcel(response, list, "工程复盘详情数据");
    }

    /**
     * 获取工程复盘详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:recoveryDetail:query')")
    @GetMapping(value = "/{recoveryDetailId}")
    public AjaxResult getInfo(@PathVariable("recoveryDetailId") Long recoveryDetailId)
    {
        return success(projectRecoveryDetailService.selectProjectRecoveryDetailByRecoveryDetailId(recoveryDetailId));
    }

    /**
     * 新增工程复盘详情
     */
    @PreAuthorize("@ss.hasPermi('project:recoveryDetail:add')")
    @Log(title = "工程复盘详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectRecoveryDetail projectRecoveryDetail)
    {
        return toAjax(projectRecoveryDetailService.insertProjectRecoveryDetail(projectRecoveryDetail));
    }

    /**
     * 修改工程复盘详情
     */
    @PreAuthorize("@ss.hasPermi('project:recoveryDetail:edit')")
    @Log(title = "工程复盘详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectRecoveryDetail projectRecoveryDetail)
    {
        return toAjax(projectRecoveryDetailService.updateProjectRecoveryDetail(projectRecoveryDetail));
    }

    /**
     * 删除工程复盘详情
     */
    @PreAuthorize("@ss.hasPermi('project:recoveryDetail:remove')")
    @Log(title = "工程复盘详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recoveryDetailIds}")
    public AjaxResult remove(@PathVariable Long[] recoveryDetailIds)
    {
        return toAjax(projectRecoveryDetailService.deleteProjectRecoveryDetailByRecoveryDetailIds(recoveryDetailIds));
    }
}
